package componentloader

import (
	"zstackgo/spring"

	"github.com/meilihao/golib/v2/log"
	"go.uber.org/zap"
)

// <bean id="AuthorizationManager" class="org.zstack.identity.AuthorizationManager">
//         <zstack:plugin>
//             <zstack:extension interface="org.zstack.header.Component"/>
//             <zstack:extension interface="org.zstack.header.apimediator.GlobalApiMessageInterceptor"/>
//             <zstack:extension interface="org.zstack.header.zql.ZQLQueryExtensionPoint"/>
//         </zstack:plugin>
//     </bean>
type PluginNameSpaceHandler struct{}

func (h *PluginNameSpaceHandler) Init() {
	// 注册自定义元素的BeanDefinition装饰器
	// this.registerBeanDefinitionDecorator("plugin", new PluginDefinitionParser());
	parser := new(PluginDefinitionParser)

	my := spring.GlobalMyContainer

	for id, exts := range my.MapExts {
		parser.Decorate(my, my.MapBeanIdDef[id], id, exts)
	}

	log.Glog.Info("impl num", zap.Int("len", len(my.MapBeanIdDef)))
	log.Glog.Info("interface num", zap.Int("len", len(my.MapInterface)))
	// fmt.Println("@@@@@@@@@@@@@@@@-struct", len(my.MapBeanIdDef))
	// for k := range my.MapBeanIdDef {
	// 	fmt.Println(k)
	// }
	// fmt.Println("@@@@@@@@@@@@@@@@-interface{}", len(my.MapInterface))
	// for k := range my.MapInterface {
	// 	fmt.Println(k)
	// }
}
